{{if validation_errors()}}
<ul class="message error">
    <li>{{validation_errors()}}</li>
</ul>
{{/if}}
<div class="clear"></div>
<form class="block-content form" id="simple_form" method="post" action="create">
    <h1>{{$advertising->lang->line('advertising')}}</h1>
    <ul class="tabs js-tabs same-height">
        <li class="current"><a href="#tab-locales" title="Locales">{{$advertising->lang->line('current')}}</a></li>
        <li><a href="#tab-options" title="Options">{{$advertising->lang->line('options')}}</a></li>
    </ul>
    <div class="tabs-content">
        <div id="tab-locales"> {{if isset($advertising->id)}}{{form_hidden('id', $advertising->id)}}{{/if}}
            <fieldset class="grey-bg required">
                <legend>{{$advertising->lang->line('required')}}</legend>
                <p>
                    <label>{{$advertising->lang->line('title')}}</label>
                    <input type="text" name="title" id="simple-required" value="{{if isset($advertising->title)}}{{$advertising->title}}{{/if}}" class="full-width">
                    {{form_error('title')}} 
                </p>
            </fieldset>
            <fieldset>
                <legend>{{$advertising->lang->line('other_info')}}</legend>
                
                <p>
                    <label>{{$advertising->lang->line('link')}}</label>
                    <input type="text" name="link" class="full-width" value="{{if isset($advertising->link)}}{{$advertising->link}}{{/if}}">
                </p>
                
                <p>
                    <label>{{$advertising->lang->line('type')}}</label>
                    <select name="type" id="simple-select" class="full-width type-select">
                        {{html_options options=$advertising->type_list() selected=$advertising->type}}
                    </select>
                </p> 
                <p>
	                <label>{{$advertising->lang->line('position')}}</label>
	                <select name="position" id="simple-select" class="full-width">
	                    {{html_options options=$advertising->position_list() selected=$advertising->position}}
	                </select>
	            </p>                
                <p>
                    <label for="resource" class="select-label">{{$advertising->lang->line('resource')}}</label>
                    <input type="text" name="resource" id="resource" class="full-width non-chtml" ondblclick="javascript:imagemanager('resource');" value="{{if isset($advertising->resource)}}{{$advertising->resource}}{{/if}}">
                    <textarea name="resource" cols="10" class="full-width text-editor chtml">{{if isset($advertising->resource)}}{{$advertising->resource}}{{/if}}</textarea>
                </p>        
            </fieldset>
        </div>
        <div id="tab-options">
        	<p>
            	<label>{{$advertising->lang->line('description')}}</label>
                <textarea name="description" cols="10" class="full-width text-editor tinymcesimple">{{if isset($advertising->description)}}{{$advertising->description}}{{/if}}</textarea>
			</p>            
            <p>
                <label>{{$advertising->lang->line('order')}}</label>
                <input type="text" name="order" class="full-width" value="{{if isset($advertising->order)}}{{$advertising->order}}{{/if}}">
            </p>
            <p>
                <label for="simple-select">{{$advertising->lang->line('partner')}}</label>
                <select name="partner_id" id="simple-select" class="full-width">
                    {{html_options options=$partner->get_list() selected=$advertising->position}}
                </select>
            </p>
            <p>
                <label for="simple-select">{{$advertising->lang->line('language')}}</label>
                <select name="lang_id" id="simple-select" class="full-width">					
                    {{html_options options=$language->get_list() selected=$advertising->language_id}}
                </select>
            </p>			
            <p>
                <label>{{$advertising->lang->line('creator')}}</label>
                <input type="text" name="creator" class="full-width" value="">
            </p>
            <div class="columns">
                <div class="colx2-left">
                    <label for="content">{{$advertising->lang->line('simple-calendar')}}</label>
                    <span class="input-type-text margin-right relative">
                        <input type="text" name="simple-calendar" id="simple-calendar" value="">
                        <img src="{{base_url()}}data/templates/backend/xgo/images/icons/fugue/calendar-month.png" width="16" height="16"> </span> </div>
                <p class="colx2-right">
                    <label for="active">{{$advertising->lang->line('active')}}</label>
                    <input type="checkbox" name="active" id="simple-switch-on" value="1" checked="checked" class="switch" onclick="$(this).setActive();">
                </p>
            </div>
        </div>
        <fieldset class="grey-bg no-margin">
            <legend>{{$advertising->lang->line('action')}}</legend>
            <p class="input-with-button">
                <button type="submit">{{$advertising->lang->line('save')}}</button>
            </p>
        </fieldset>
    </div>
</form>

<script type="text/javascript">
function isTextarea(){
	$('.chtml').hide();
    $('.non-chtml').hide();
    var code = $('.type-select').val();
	if(code == 'image' || code == 'youtube'|| code =='flash'){
    	$('.non-chtml').show();
        $('.non-chtml').attr('name','resource');
        $('.chtml').attr('name','none');
	}else if(code == 'code'){
    	$('.chtml').show();
        $('.non-chtml').attr('name','none');
        $('.chtml').attr('name','resource');
		}
    }
    function labelSelect(){
    	var text = $('.type-select').find('option:selected').attr('vkey');                          
        	$('.select-label').html(text);
		}
        $(document).ready(function(){
        	labelSelect();
            isTextarea();
            $('.type-select').change(function(){                      
            labelSelect();
            isTextarea();
		});
	});
</script>